<template>
  <div class='app-menu-wrapper'>
    <ul class='menu-group-list'>
      <li v-for='(group, groupIndex) of menus'
          :key='"group" + groupIndex'>
        <div class='menu-group-item' v-show='group.isShow'>
          <div class='group-title'>{{group.title}}</div>
          <ul class='group-menus'>
            <li v-for='(menu, index) of group.menus'
                :key='"menu" + index'>
              <div class='menu-item'
                   v-show='menu.isShow'
                  :class='{active: menu.name === activeMenuName}'
                  @click='selecyMenu(menu)'>
                {{menu.title}}
              </div>
            </li>
          </ul>
          <div class='group-split'>
            <p></p>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'appMenu',
  data () {
    return {}
  },
  props: {
    // 应用菜单列表
    menus: {
      type: Array,
      default () {
        return []
      }
    },
    // 当前高亮菜单名
    activeMenuName: {
      type: String,
      default: ''
    }
  },
  methods: {
    selecyMenu (menu) {
      this.$emit('selectMenu', menu)
    }
  }
}
</script>

<style lang="stylus" scoped>
.app-menu-wrapper
  scroll()
  width 130px
  background #fafafa
  padded_box(border-box, 10px)
  .menu-group-list
    .menu-group-item
      font-size: 12px;
      position: relative;
      margin: 2px 0;
      display: block;
      color: #595961;
      line-height 17px
      .group-title
        padding: 12px 10px;
        font-weight: 700;
        font-size: 12px;
        color #000
        font-weight 700
      .group-menus
        .menu-item
          padding: 12px 10px 12px 12px;
          font-size: 12px;
          position: relative;
          margin: 2px 0;
          display: block;
          color: #595961;
          cursor pointer
          line-height 17px
          &:hover, &.active
            color: #35323b;
            background: #e9eaf0;
            border-radius: 6px;
          &.active
            &::after
              content: ''
              width: 0;
              height: 0;
              border-color: transparent transparent transparent #000;
              border-style: solid;
              border-width: 4px 0 4px 6px;
              position: absolute;
              right: 10px;
              top: 16px;
      .group-split
        padding: 12px 10px;
        p
          height: 1px;
          background: #e3e2e5;
          margin: 0;
</style>
